<!-- include tpl=head title=$cate_rs.title menutitle=$page_rs.title -->
<script type="text/javascript">
function attr_select(id,aid)
{
	$("#attr_"+aid).val(id);
	$("div[name=attr"+aid+"]").each(function(i){
		var tid = $(this).attr('data');
		if(tid == id){
			$(this).addClass("selected");
			//判断价格
			var new_price = $(this).attr("price");
			if(new_price && parseFloat(new_price)>0){
				price = parseFloat(price) + parseFloat(new_price);
				$("#showprice").html(price);
			}
		}else{
			$(this).removeClass('selected');
		}
	});
	var price = '{$rs.price}';
	$("input[name=attr]").each(function(i){
		var val = $(this).val();
		if(val){
			var newprice = $("div[data="+val+"]").attr("price");
			if(newprice && parseFloat(newprice)>0){
				price = parseFloat(price) + parseFloat(newprice);
			}
		}
	});
	var url = api_url('cart','price_format','price='+$.str.encode(price));
	$.phpok.json(url,function(rs){
		if(rs.status){
			$("#showprice").html(rs.info);
		}
	});
}
$(document).ready(function(){
	$("#minus").click(function(){
		var o = $("#buycount").val();
		if(o<2){
			$.dialog.alert('要购买的数量不能少于1');
			return false;
		}
		o = parseInt(o) - 1;
		$("#buycount").val(o);
	});
	$("#plus").click(function(){
		var o = $("#buycount").val();
		o = parseInt(o) + 1;
		$("#buycount").val(o);
	});
});
</script>
<!-- if $rs.pictures || $rs.thumb -->
<div data-am-widget="slider" class="am-slider am-slider-a5" data-am-slider='{"directionNav":false}'>
	<ul class="am-slides">
		<!-- if !$rs.pictures && $rs.thumb -->
		<li><img src="{$rs.thumb.gd.auto}" alt="{$rs.title}" /></li>
		<!-- /if -->
		<!-- loop from=$rs.pictures key=$key value=$value -->
		<li><img src="{$value.gd.auto}" alt="{$value.title}" /></li>
		<!-- /loop -->
	</ul>
</div>
<!-- /if -->
<div class="main">
	<h2>{$rs.title}</h2>
	<ul class="am-list am-list-static">
		<li>
			<div class="am-g">
				<div class="am-u-sm-4"><b>查看次数</b></div>
				<div class="am-u-sm-8">{$rs.hits}</div>
			</div>
		</li>
		<li>
			<div class="am-g">
				<div class="am-u-sm-4"><b>添加时间</b></div>
				<div class="am-u-sm-8">{func time_format $rs.dateline}</div>
			</div>
		</li>
		<!-- loop from=$rs.attrlist key=$key value=$value -->
		<li>
			<div class="am-g">
				<div class="am-u-sm-4"><b>{$value.title}</b></div>
				<div class="am-u-sm-8">
					<input type="hidden" name="attr" id="attr_{$value.id}" value="" />
					<!-- loop from=$value.rslist key=$k value=$v id=$tmpid -->
					<div class="attr" name="attr{$value.id}" data="{$v.id}" price="{$v.price}" weight="{$v.weight}" volume="{$v.volume}" onclick="attr_select('{$v.id}','{$value.id}')">{$v.title}</div>
					<!-- /loop -->
				</div>
			</div>
		</li>
		<!-- /loop -->
		<li>
			<div class="am-g">
				<div class="am-u-sm-4"><b>购买数量：</b></div>
				<div class="am-u-sm-8 am-form">
					<input name="buycount" id="buycount" value="1" type="number" min="1" />
				</div>
			</div>
		</li>
		<li>
			<div class="am-g">
				<div class="am-u-sm-4"><b>价格</b></div>
				<div class="am-u-sm-8"><span class="price" style="color:red;font-size:16px;" id="showprice">{func price_format $rs.price $rs.currency_id}</span></div>
			</div>
		</li>
	</ul>
	<div align="center">
		<button type="button" class="am-btn am-btn-primary" onclick="$.cart.add('{$rs.id}',$('#buycount').val())"><i class="am-icon-shopping-cart"></i> 加入购物车</button>
		<button type="button" class="am-btn am-btn-secondary" onclick="$.cart.onebuy('{$rs.id}',$('#buycount').val())"><i class="am-icon-check"></i> 立即购买</button>
	</div>
</div>
<div class="clear"></div>
<div data-am-widget="tabs" class="am-tabs am-tabs-d2">
	<ul class="am-tabs-nav am-cf">
		<li class="am-active"><a href="[data-tab-panel-0]">介绍</a></li>
		<!-- if $rs.pictures --><li><a href="[data-tab-panel-1]">图集</a></li><!-- /if -->
		<!-- if $rs.package --><li><a href="[data-tab-panel-2]">包装</a></li><!-- /if -->
		<li><a href="[data-tab-panel-3]">售后</a></li>
		<!-- if $page_rs.comment_status --><li><a href="[data-tab-panel-4]">评价</a></li><!-- /if -->
	</ul>
	<div class="am-tabs-bd">
		<div data-tab-panel-0 class="am-tab-panel am-active">{$rs.content}</div>
		<!-- if $rs.pictures -->
		<div data-tab-panel-1 class="am-tab-panel ">
			<!-- loop from=$rs.pictures key=$key value=$value id=$tmpid -->
			<p align="center"><img src="{$value.gd.auto}" border="0" style="max-width:100%" /></p>
			<!-- /loop -->
		</div>
		<!-- /if -->
		<!-- if $rs.package -->
		<div data-tab-panel-2 class="am-tab-panel "></div>
		<!-- /if -->
		<div data-tab-panel-3 class="am-tab-panel "><!-- php:$t = phpok('after-sale-protection') -->{$t.content}</div>
		<!-- if $page_rs.comment_status -->
		<div data-tab-panel-4 class="am-tab-panel "><!-- include tpl=block/comment tid=$rs.id --></div>
		<!-- /if -->
	</div>
</div>

<!-- include tpl=foot -->
